/***********************************************************************
*	sample ucos ii 2416 probe
* author: qingluo
* date: april-22-2013
* version: v1.0
***********************************************************************/
#define OS_CPU_GLOBALS
#include <includes.h>

OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
{
    INT32U *stk;


    	opt    = opt;                           /* 'opt' is not used, prevent warning                      */
    	stk    = (INT32U *)ptos;                /* Load stack pointer                                      */
	*(--stk) = (INT32U)task;				/* Entry Point .. -> PC								       */
    	*(--stk) = (INT32U)0;                   /* r14                                                     */
    	*(--stk) = (INT32U)0;                   /* r12                                                     */
    	*(--stk) = (INT32U)0;                   /* r11                                                     */
    	*(--stk) = (INT32U)0;                   /* r10                                                     */
    	*(--stk) = (INT32U)0;                   /* r9                                                      */
    	*(--stk) = (INT32U)0;                   /* r8                                                      */
    	*(--stk) = (INT32U)0;                   /* r7                                                      */
    	*(--stk) = (INT32U)0;                   /* r6                                                      */
    	*(--stk) = (INT32U)0;                   /* r5                                                      */
    	*(--stk) = (INT32U)0;                   /* r4                                                      */
    	*(--stk) = (INT32U)0;                   /* r3                                                      */
    *(--stk) = (INT32U)0;                   /* r2                                                      */
    *(--stk) = (INT32U)0;                   /* r1                                                      */
    *(--stk) = (INT32U)pdata;               /* r0 : argument                                           */
    *(--stk) = (INT32U)0x00000013L;					/* CPSR		model tel here 0x00000013L SVC mode  */

    return ((void *)stk);
} 

#if OS_APP_HOOKS_EN > 0
void OSInitHookBegin(void)
{

}

void OSInitHookEnd(void)
{
}

void OSTaskCreateHook(OS_TCB * ptcb)
{
	ptcb = ptcb;
}

void OSTaskDelHook(OS_TCB * ptcb)
{
	ptcb = ptcb;
}

void OSTaskStatHook(void)
{
}

void OSTaskSwHook(void)
{

}

void OSTCBInitHook(OS_TCB * ptcb)
{
	ptcb = ptcb;
}

void OSTimeTickHook(void)
{

}

#endif // OS_CPU_HOOKS_EN > 0
void OSTaskIdleHook(void)
{
}
void OSTaskReturnHook(OS_TCB *ptcb)
{
	ptcb = ptcb;
}
/*
void OS_CPU_SysTickInit(void)
{

	INT32U cnts;
	cnts = OS_CPU_SysTickClkFreq() / OS_TICKS_PER_SEC;
	//2416_tmr_reloadcount = (cnts - 1);
	//2416_tmr_control = TMR_ENABLE | TMR_CLR_DIV
	//2416_tmr_interrupt_control == enable timer of 2416

}*/

